// Copyright (C) 2010 Razvan Constantin <razvan.constantin@rconst.net>
//
// This file is part of FileBow.
//
// FileBow is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// FileBow is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with FileBow.  If not, see <http://www.gnu.org/licenses/>.

#include "logic/history.h"

#include <gtest/gtest.h>
#include <memory>
#include <Poco/Path.h>

#include "logic/file-scorer.h"

using namespace std;
using Poco::Path;

namespace filebow {

TEST(HistoryTest, TestScore) {
  History history;
  history.TrackOpen("/tmp/file11");
  history.TrackOpen("/tmp/file12");
  history.TrackOpen("/tmp/file13");
  history.TrackOpen("/tmp/file11");
  PathTree tree;
  PathTree::Node* f1 = tree.Insert("/tmp/file11");
  PathTree::Node* f2 = tree.Insert("/tmp/file12");
  PathTree::Node* f3 = tree.Insert("/tmp/file13");
  PathTree::Node* f4 = tree.Insert("/tmp/file14");
  auto_ptr<FileScorer> scorer(history.GetScorer(&tree));
  EXPECT_LT(0, scorer->ScoreFile(f1));
  EXPECT_LT(0, scorer->ScoreFile(f2));
  EXPECT_LT(0, scorer->ScoreFile(f3));
  EXPECT_LT(scorer->ScoreFile(f2), scorer->ScoreFile(f1));
  EXPECT_EQ(0, scorer->ScoreFile(f4));
}

} // namespace filebow
